<form class="normal_form" form-role="dialog" onsubmit="return Core.DialogForm(this)" style="padding-top:20px;margin-bottom:0;" autocomplete="off">
    <div class="row">
        <div class="field_text">包厢类型：</div>
        <select class="z-select sel-btype" id="btype" data-style="width:200px">
            <option value="">请选择</option>
            <!--{if ($btype ?? NULL)}-->
            <!--{foreach $btype as $key => $row}-->
            <option value="{$row['id'] ?? ''}" {if ($res['btype'] ?? 0)==($row['id'] ?? 0)} selected{/if}>{$row['title'] ?? ''}</option>
            <!--{/foreach}-->
            <!--{/if}-->
        </select>
    </div>
    <div class="row">
        <div class="field_text">楼层：</div>
        <select class="z-select sel-floor" id="floor" data-style="width:200px">
            <option value="">请选择</option>
            <!--{if ($floor ?? NULL)}-->
            <!--{foreach $floor as $key => $row}-->
            <option value="{$row['id'] ?? ''}" {if ($res['floor'] ?? 0)==($row['id'] ?? 0)} selected{/if}>{$row['title'] ?? ''}</option>
            <!--{/foreach}-->
            <!--{/if}-->
        </select>
    </div>
    <div class="row">
        <div class="field_text">包厢名称：</div>
        <input type="text" name="title" value="{$res['title'] ?? ''}" class="input-text require" style="width:200px;" placeholder="请输入名称" />
    </div>
    <div class="row">
        <div class="field_text">最低消费：</div>
        <input type="text" name="coperto" value="{$res['coperto'] ?? ''}" class="input-text" style="width:200px;" placeholder="请设置包厢最低消费金额" /> 元
    </div>
    <div class="row">
        <div class="field_text">排序ID：</div>
        <input type="text" name="iorder" value="{$res['iorder'] ?? ''}" class="input-text" style="width:200px;" placeholder="请设置排序" />
    </div>
    <div class="row form-footer-bar">
        <p class="colortip"></p>
        <button class="btn" role="btn-cancel">取消</button>
        <button class="btn btn-primary" type="submit" role="btn-submit">保存</button>
    </div>
</form>
<script type="text/javascript">
Core.DialogForm = function(form){    
    var form = $(form);
    var p = {
        'btype'     : $(".sel-btype").getZsValue(),
        'floor'     : $(".sel-floor").getZsValue(),
        'title'     : form.find(":text[name='title']").val(),
        'coperto'   : form.find(":text[name='coperto']").val(),
        'iorder'    : form.find(":text[name='iorder']").val(),
    }
    if (!Core.rule('*',p['title'])) {
        form.find("p.colortip").html('请输入包厢名称!');return false;
    } else if (p['coperto']!='' && !Core.rule('*',p['money'])) {
        form.find("p.colortip").html('请设置包厢最低消费金额!');return false;
    } else if (!Core.rule('intps',p['iorder'])) {
        form.find("p.colortip").html('请设置排序!');return false;
    }
    
    form.find(":button").attr('disabled','disabled');
	$.ajax({type : "POST",dataType: "json",cache : false, url : "{$_G['_mc_'] ?? ''}/edit/id/{$res['id'] ?? ''}?r="+Math.random(),data : p,success: function(data){
	   try{
		   if (data['state'] == 'y'){
			   $("#datalist").datagrid('reload');$(form).dialogClose();
		   } else {
			   form.find(":button").removeAttr('disabled');form.find("p.colortip").html(data['msg']);return false;
		   }
	   }catch(e){form.find(":button").removeAttr('disabled');form.find("p.colortip").html('数据提交失败!');return false;}
	}});
	return false;
}
</script>